package com.xy.biz.xd.domain.converter;

import com.xy.biz.xd.domain.bo.DocumentFlowBO;
import com.xy.biz.xd.domain.bo.DocumentFlowNewAndModifyBO;
import com.xy.biz.xd.domain.po.DocumentFlowPO;
import com.xy.biz.xd.domain.query.DocumentFlowQuery;
import com.xy.biz.xd.domain.req.*;
import com.xy.biz.xd.domain.resp.GetDocumentFlowResponse;
import com.xy.biz.xd.domain.resp.ListDocumentFlowBrorowAndPrintAndDropResponse;
import com.xy.biz.xd.domain.resp.ListDocumentFlowNewAndModifyResponse;
import com.xy.lang.domain.PageRequest;
import com.xy.tool.util.BeanUtilsEx;

import java.util.Collection;
import java.util.List;

/**
 *
 *
 * @author zsp
 * @date 2021-1-22
 */
public class DocumentFlowConverter {

	public static DocumentFlowPO toPO(DocumentFlowBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowPO(), true);
	}

	public static List<DocumentFlowPO> toPO(Collection<DocumentFlowBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentFlowPO(), true);
	}

	public static DocumentFlowBO fromPO(DocumentFlowPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowBO());
	}

	public static List<DocumentFlowBO> fromPO(Collection<DocumentFlowPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentFlowBO());
	}

	public static DocumentFlowBO toBO(SaveDocumentFlowRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowBO(), true);
	}

	public static DocumentFlowBO toBO(EditDocumentFlowNewRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowBO(), true);
	}

	public static DocumentFlowBO toBO(EditDocumentBorrowRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowBO(), true);
	}

	public static DocumentFlowBO toBO(ApplyDocumentFlowModifyRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowBO(), true);
	}

	public static GetDocumentFlowResponse toResponse(DocumentFlowBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetDocumentFlowResponse());
	}

	public static ListDocumentFlowBrorowAndPrintAndDropResponse toResponseList(DocumentFlowBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ListDocumentFlowBrorowAndPrintAndDropResponse());
	}

	public static List<ListDocumentFlowBrorowAndPrintAndDropResponse.DocumentFlowInfo> toResponseList(Collection<DocumentFlowBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ListDocumentFlowBrorowAndPrintAndDropResponse.DocumentFlowInfo());
	}

	public static List<GetDocumentFlowResponse> toResponse(Collection<DocumentFlowBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentFlowResponse());
	}

	public static DocumentFlowQuery toQuery(ListDocumentFlowRequest source) {
		if(null == source) {
			return null;
		}
		DocumentFlowQuery target = new DocumentFlowQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

	public static DocumentFlowQuery toQuery(ListLedgerDataRequest source) {
		if(null == source) {
			return null;
		}
		DocumentFlowQuery target = new DocumentFlowQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

	public static DocumentFlowQuery toQuery(PageRequest source) {
//		if(null == source) {
//			return null;
//		}
		DocumentFlowQuery target = new DocumentFlowQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}
}
